﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FineSoft.Models
{
	public class ComponentClass : ExtClass
	{
		//public string XType;
		private bool? _IsContainer;
		public bool IsContainer
		{
			get
		    {
		        if (this._IsContainer == null)
		        {
					for (ExtClass parentClass = this.Parent; parentClass != null; parentClass = parentClass.Parent)
						if (parentClass == Class.AbstractContainer)
							this._IsContainer = true;
					if (this._IsContainer == null)
						this._IsContainer = false;
		        }
				return this._IsContainer.Value;
		    }
		}

		private ContainerConfig[] _ContainerConfigs;
		public ContainerConfig[] ContainerConfigs
		{
			get
			{
				if (this._ContainerConfigs == null)
					this._ContainerConfigs = this.Configs.Where(c => c.GetType() == typeof(ContainerConfig)).OrderBy(c => c.Name != "items").OfType<ContainerConfig>().ToArray();
				return this._ContainerConfigs;
			}
		}
	}
}